package main

import (
	"log"
	"os"
	"io/ioutil"
	"io"
)


var (
	Trace *log.Logger
	Info *log.Logger
	Warn *log.Logger
	Error *log.Logger
)

func main() {

	Trace.Println("Trace info")
	Info.Println("Spec info")
	Warn.Println("Warn info")
	Error.Println("hava failed")

}

func init()  {

	file, error := os.OpenFile("./logs/errors.txt", os.O_CREATE|os.O_APPEND, 0666)

	if error != nil {
		log.Fatalln("Failed to open file", error)
	}

	Trace = log.New(ioutil.Discard, "Trace: ", log.Ldate|log.Ltime|log.Lshortfile)
	Info = log.New(os.Stdout, "Info: ", log.Ldate|log.Ltime|log.Lshortfile)
	Warn = log.New(os.Stdout, "Warn: ", log.Ldate|log.Ltime|log.Lshortfile)
	Error = log.New(io.MultiWriter(file, os.Stderr), "Error: ", log.Ldate|log.Ltime|log.Lshortfile)

	
}
